package com.jinxiangyang.utils.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @author jinxiangyang
 * @date 2023/8/11 16:30
 * @description TODO
 **/



@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

    @Value("${swagger.enable}")
    private Boolean enable;

    @Bean(value = "defaultApi2")
    public Docket defaultApi2() {
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(enable)
                .apiInfo(
                        new ApiInfoBuilder()
                                .description("在线教育接口文档")
                                .termsOfServiceUrl("https://www.jingxiangyang.top/")
                                .contact(new Contact("edu", "www.edu.com", "12334556@qq.com"))
                                .version("1.0")
                                .build()
                )
                //分组名称
                .groupName("1.0版本")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.jinxiangyang.controller"))
                .paths(PathSelectors.any())
                .build();
    }
}

